<?php

namespace App\Http\Controllers;

use App\Activity;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class ActivityController extends Controller
{
	//
	public function items()
	{
		$activities = Activity::where('status', '=', 1)->limit(10)->get();
		$data = [];
		if($activities && is_object($activities)){
			foreach ($activities as $activity){
				$data[] = array(
					'title'=>$activity->name,
					'desc'=>$activity->content,
					'src'=>$activity->image,
					'url'=>url('detail',['id'=>$activity->id]),
					'meta'=>array(
						'source'=>'博森美',
						'date'=>$activity->start_time,
						'other'=>$activity->price
					)
				);
			}
		}
		return response()->json($data);
	}

	public function detail()
	{

	}

	public function join(Request $request, Response $response){
		dd($request->all());
	}
}
